package com.sxbbc.api.controller;

import com.function.common.GetRest;
import com.function.common.RestResponse;
import com.sxbbc.api.common.AgreeMapping;
import com.sxbbc.common.core.entity.jz.SysAgreement;
import com.sxbbc.common.core.service.ISysAgreementService;
import com.sxbbc.common.core.service.system.login.LoginTokenService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * 协议 控制层
 *
 * @author leehao
 * @date 2019-06-01 17:47
 */
@Cacheable(value = "bbcCache",key = "'queryAgree'")
@RestController
public class AgreeController {

    @Autowired
    private ISysAgreementService sysAgreementService;
    @Autowired
    private LoginTokenService loginTokenService;

    /**
     * 入驻协议
     * @author leehao
     * @return com.function.common.RestResponse
     */
    @GetMapping(value = AgreeMapping.SHOW_PRIVACY_AGREE)
    public RestResponse showPrivacyAgree(){
        Integer type = 17;
        SysAgreement agree = sysAgreementService.getById(type);
        return GetRest.getSuccess("success",agree);
    }

    /**
     * 入驻协议
     * @author leehao
     * @return com.function.common.RestResponse
     */
    @GetMapping(value = AgreeMapping.SHOW_SETTLED_AGREE)
    public RestResponse showSettledAgree(){
        Integer type = 1;
        SysAgreement agree = sysAgreementService.getById(type);
        return GetRest.getSuccess("success",agree);
    }

    /**
     * 用户协议
     * @author leehao
     * @return com.function.common.RestResponse
     */
    @GetMapping(value = AgreeMapping.SHOW_CUSTOMER_AGREE)
    public RestResponse showCustomerAgree(){
        Integer type = 2;
        SysAgreement agree = sysAgreementService.getById(type);
        return GetRest.getSuccess("success",agree);
    }
    
    /**
     * 用户权益
     * @return com.function.common.RestResponse
     * @author xiaoky
     */
    @GetMapping(value = AgreeMapping.SHOW_CUSTOMER_RIGHTS)
    public RestResponse showCustomerRights () {
    	Integer type = 3;
        SysAgreement agree = sysAgreementService.getById(type);
        return GetRest.getSuccess("success",agree);
    }

    /**
     * 证照信息
     * @return com.function.common.RestResponse
     * @author xiaoky
     */
    @GetMapping(value = AgreeMapping.SHOW_CERTIFICATE)
    public RestResponse showCertificate () {
    	Integer type = 4;
    	SysAgreement agree = sysAgreementService.getById(type);
    	return GetRest.getSuccess("success",agree);
    }
    /**
     * 关于我们
     * @return com.function.common.RestResponse
     * @author xiaoky
     */
    @GetMapping(value = AgreeMapping.SHOW_ABOUT_US)
    public RestResponse showAboutUs () {
    	Integer type = 5;
    	SysAgreement agree = sysAgreementService.getById(type);
    	return GetRest.getSuccess("success",agree);
    }
    
    /**
     * 平台联系客服
     * @return com.function.common.RestResponse
     * @author xiaoky
     */
    @GetMapping(value = AgreeMapping.SHOW_PLAT_SERVICE)
    public RestResponse showPlatService () {
    	Integer type = 6;
    	SysAgreement agree = sysAgreementService.getById(type);
    	return GetRest.getSuccess("success",agree);
    }

    /**
     * 积分规则
     * @author leehao
     * @return com.function.common.RestResponse
     */
    @GetMapping(value = AgreeMapping.SHOW_POINT_RULE)
    public RestResponse showPointRule(){
        Integer type = 7;
        SysAgreement agree = sysAgreementService.getById(type);
        return GetRest.getSuccess("success",agree);
    }

    /**
     * 代理入驻规则
     * @return
     */
    @GetMapping(value = AgreeMapping.SHOW_AGENT_RULE)
    public RestResponse showAgentProRule(){

        HashMap<String, Object> map = new HashMap<>();
        Integer protype = 10;
        SysAgreement proAgree = sysAgreementService.getById(protype);
        Integer citytype = 11;
        SysAgreement cityAree = sysAgreementService.getById(citytype);
        Integer areatype = 12;
        SysAgreement areaAgree = sysAgreementService.getById(areatype);
        map.put("proAgree",proAgree);
        map.put("cityAree",cityAree);
        map.put("areaAgree",areaAgree);
        return GetRest.getSuccess("success",map);
    }

    /**
     * 养鸡规则
     * @return
     */
    @GetMapping(value = AgreeMapping.SHOW_CHICKEN_RULE)
    public RestResponse showChickenRule(){
        Integer type = 13;
        SysAgreement agree = sysAgreementService.getById(type);
        return GetRest.getSuccess("success",agree);
    }


    /**
     * 提鸡券规则
     * @return
     */
    @GetMapping(value = AgreeMapping.SHOW_CHICKENCOUPON_RULE)
    public RestResponse showChickenCouponRule(){
        Integer type = 14;
        SysAgreement agree = sysAgreementService.getById(type);
        return GetRest.getSuccess("success",agree);
    }


    /**
     * 预约提鸡规则
     * @return
     */
    @GetMapping(value = AgreeMapping.SHOW_CHICKENSUBSCRIBE_RULE)
    public RestResponse showChickenSubscribeRule(){
        Integer type = 15;
        SysAgreement agree = sysAgreementService.getById(type);
        return GetRest.getSuccess("success",agree);
    }

}
